package com.le.tester.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * 描述：swagger接口文档配置
 */
@Configuration
@EnableSwagger2
public class Swagger2Config {

    @Value("${swagger2.show}")
    private boolean enable;

    @Bean
    public Docket createApiInfo() {
        return new Docket(DocumentationType.SWAGGER_2).apiInfo(getApiInfo())
                .enable(enable)
                .select()
                .paths(PathSelectors.any())
                .build();

    }

    private ApiInfo getApiInfo() {
        return new ApiInfoBuilder()
                .title("LeTester接口定义和规范")
                .description("接口全部为post请求方式")
                .termsOfServiceUrl("https://www.baidu.com")
                .contact(new Contact("Mountain Top Technical Team", "www.mountaintop.com", "@.com"))
                .version("1.0.0")
                .license("版权所有@...")
                .build();
    }
}
